package wfm.activiti;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.activiti.engine.impl.el.Expression;

import wfm.entities.Ticket;
import wfm.query.QueryDao;

public class RequestWorkerBehavior implements JavaDelegate
{
	
	@Override
	public void execute(DelegateExecution execution) throws Exception 
	{

		System.out.println("--> Request of Worker!");
		
		Ticket ticket = (Ticket)QueryDao.getVariableToProcessById(execution.getId(), "ticket");
		
		ticket.setAssignedWorker(ticket.getSelectedPartner().getWorker());
		
		QueryDao.saveVariableToProcessById(execution.getId(), "ticket", ticket);
		
		execution.setVariable("ticket", ticket);
	}
}
